import config from '../config'

export function getTemplate(template) {
    if (template === '') {
        var _template = window.localStorage.getItem('_template')
    }
    template = template || _template || config.custom.template
    if (template !== _template) {
        window.localStorage.setItem('_template', template)
    }
    return template
}

export function getLanguage(language) {
    if (language === '' || language === undefined) {
        var _language = window.localStorage.getItem('_language')
    }
    language = language || _language || config.custom.language
    if (language !== _language) {
        window.localStorage.setItem('_language', language)
    }
    return language
}

export function getUrlQuery(keyName) {
    var reg = new RegExp('(^|&)' + keyName + '=([^&]*)(&|$)')
    var queryStr = window.location.hash.match(reg)
    if (queryStr !== null) { return queryStr[2] }
    return
}

